package org.example.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;

/**
 * @Author 李荣
 * @Date 2025/2/7
 * @Description
 */

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LogInfo {

    private Date date;

    private String deviceId;

    private String level;

    private String description;

    public LogInfo(String[] split) {
        try {
            this.date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(split[0]);
            this.deviceId = split[1];
            this.level = split[2];
            this.description = split[3];
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}
